/**
 * Created by su on 2017/8/22.
 * 大鱼 API translate();rotate()旋转.angle指旋转的角度，顺时针旋转;Math.atan2(y,x);
 */
var momObj = function () {
    this.x;
    this.y;
    this.angle;
    this.bigEye = new Image();
    this.bigBody = new Image();
    this.bigTail = new Image();
}

momObj.prototype.init = function () {
    this.x = canWidth * 0.5;
    this.y = canHeight * 0.5;
    this.angle = 0;
    this.bigEye.src = "./src/bigEye0.png";
    this.bigBody.src = "./src/bigSwim0.png";
    this.bigTail.src = "./src/bigTail0.png";
}

momObj.prototype.draw = function () {

    //大鱼随着鼠标移动
    this.x = lerpDistance(mx, this.x, 0.95);
    this.y = lerpDistance(my, this.y, 0.95);

    var deltaY = my - this.y;
    var deltaX = mx - this.x;
    var  beta = Math.atan2(deltaY, deltaX) + Math.PI;

    this.angle = lerpAngle(beta, this.angle, 0.6);

    ctx1.save();
    ctx1.translate(this.x ,this.y); //法转换画布的用户坐标系统。平移，将画布的坐标原点向左右方向移动x，向上下方向移动y.canvas的默认位置是在（0,0）*/
    ctx1.rotate(this.angle);
    ctx1.drawImage(this.bigEye, -this.bigEye.width * 0.5, -this.bigEye.height * 0.5);
    ctx1.drawImage(this.bigBody, -this.bigBody.width * 0.5, -this.bigBody.height * 0.5);
    ctx1.drawImage(this.bigTail, -this.bigTail.width * 0.5 + 30, -this.bigTail.height * 0.5);
    ctx1.restore();
}
